<%--
  Created by IntelliJ IDEA.
  User: 54110
  Date: 2021/9/13
  Time: 10:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>Title</title>
</head>
<script src="${pageContext.request.contextPath}/js/jquery-3.5.1.js"></script>
<body>
    <div>
        <table border="1">
            <tr>
                <th>id</th>
                <th>姓名</th>
                <th>年龄 </th>
                <th>性别</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${teacherlist}" var="teacher">
                <tr>
                    <td>${teacher.id}</td>
                    <td>${teacher.teacherName}</td>
                    <td>${teacher.age}</td>
                    <td>${teacher.sex}</td>
                    <td>
                        <button onclick="del(${teacher.id})">删除</button>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </div>
</body>
<script>
    function del(id){
        $.ajax({
            url:"${pageContext.request.contextPath}/del?id="+id,
            type:"get",
            dataType:"json",
            success:function (data){
                alert(data);
            },
            error:function (msg){
                alert(msg);
            }
        })
    }

</script>
</html>
